package com.h5lib.nchuoffice;

import java.io.IOException;

import junit.framework.TestCase;

import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.h5lib.nchuoffice.constants.SysConstant;

/**
 * 
 * @author 抓取
 *
 */
public class SunGlasswareHouse extends TestCase{
	
	private String url = "http://www.sunglasswarehouse.com/pwr/content/02/53/SW540432-en_US-1-reviews.js";
	
	
    public void testSpider() throws IOException
    {
    	NetUtil.setProxy("10.50.152.250", "8080");
    	
		Response response = Jsoup.connect(url)
				.header("User-Agent", SysConstant.USER_AGENT)
				.header("Host", SysConstant.HOST)
				.header("Referer", SysConstant.REFERER)
				.ignoreContentType(true)
				.header("Content-Type", "application/x-www-form-urlencoded")
				.timeout(SysConstant.TIMEOUT)
				.method(Method.GET).execute();
		String body = response.body();
		body = body.substring(body.indexOf("=")+1,body.lastIndexOf(";"));
		JSONArray parseArray = JSON.parseArray(body);
		for (Object object : parseArray) {
			System.out.println(object);
		}
		
		
    }
}
